package com.stylefeng.guns.rest.modular.wz.util;

import com.stylefeng.guns.rest.modular.auth.util.JwtTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class TokenUtil {

    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    /**
     * //生成token
     * @param userCode
     * @return
     */
    public  Map getToken(Long userCode){
        String randomKey = jwtTokenUtil.getRandomKey();
        String accessToken = jwtTokenUtil.accessToken(userCode.toString(), randomKey);//短效token
        String refreshToken = jwtTokenUtil.refreshToken(userCode.toString(), randomKey);//长效token
        Map map = new HashMap();
        map.put("randomKey",randomKey);
        map.put("accessToken",accessToken);
        map.put("refreshToken",refreshToken);
//        map.put("userCode",userCode);
        return map;
    }
}
